package com.CI.Contact.Business
{
	import com.CI.Contact.VO.OpinionVO;
	import com.CI.RequestCourse.VO.RequestVO;
	
	import mx.rpc.AsyncToken;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;
	
	public class ContactDelegate
	{
		protected var responder : Responder;
		
		public function ContactDelegate()
		{
			this.responder = responder;
		}
		
		public function sendObject(obj : Object) : void
		{   
			var params : Object = new Object();
			var service : HTTPService;
			var token : AsyncToken;
			var responder:mx.rpc.Responder;
			
			if(obj is RequestVO)
			{
				var request : RequestVO = new RequestVO();
				request = obj as RequestVO;
				params.action = 'RequestCourse';
				params.nameSender = request.nameSender;
				params.organization = request.organization;
				params.title = request.title;
				params.email = request.email;
				params.telephone = request.telephone;
				params.nameCourse = request.nameCourse;
				params.time = request.time;
				params.location = request.location;
				params.number = request.number;
				params.experience = request.experience;
				params.objectif = request.objectif;
				
				service = ServiceLocator.getInstance().getHTTPService("RequestCourse");
		    	
		    	token = service.send(params);
				responder = new mx.rpc.Responder(Add_onResult, Add_onFault);
				token.addResponder(responder);
			}
			else
			{
				var opinion : OpinionVO = new OpinionVO();
				opinion = obj as OpinionVO;
				
				params.action = 'SendOpinion';
				params.nameSender = opinion.nameSender;
				params.organization = opinion.organization;
				params.title = opinion.title;
				params.email = opinion.email;
				params.telephone = opinion.telephone;
				params.content = opinion.content;
				
				service = ServiceLocator.getInstance().getHTTPService("SendOpinion");
		    	
		    	token = service.send(params);
				responder = new mx.rpc.Responder(Add_onResult, Add_onFault);
				token.addResponder(responder);
			}
		}
		
		protected function Add_onResult(event:ResultEvent) : void
		{
			
		}
		
		protected function Add_onFault(event:FaultEvent) : void
		{
		
		}
	}
}